<?php
class ControllerModuleJournal2FullscreenSlider extends Controller {

    public function __construct($registry) {
        parent::__construct($registry);
        if (!defined('JOURNAL_INSTALLED')) {
            return;
        }
        $this->load->model('journal2/module');
    }

    public function index($setting) {
        if (!defined('JOURNAL_INSTALLED')) {
            return;
        }
        static $module = 0;

        $module_data = $this->model_journal2_module->getModule($setting['module_id']);
        if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) return;

        if (Journal2Utils::getProperty($module_data, 'module_data.disable_mobile') && ($this->journal2->mobile_detect->isMobile() && !$this->journal2->mobile_detect->isTablet())) {
            return;
        }

        $this->data['transition'] = Journal2Utils::getProperty($module_data, 'module_data.transition', 'fade');
        $this->data['transition_speed'] = Journal2Utils::getProperty($module_data, 'module_data.transition_speed', '700');
        $this->data['transition_delay'] = Journal2Utils::getProperty($module_data, 'module_data.transition_delay', '3000');
        $this->data['transparent_overlay'] = 'image/' . Journal2Utils::getProperty($module_data, 'module_data.transparent_overlay', '');

        $this->data['images'] = array();

        $images = Journal2Utils::getProperty($module_data, 'module_data.images', array());
        $images = Journal2Utils::sortArray($images);

        foreach ($images as $image) {
            if (!$image['status']) continue;
            $this->data['images'][] = array(
                'image' => 'image/' . $image['image'],
                'title' => ''
            );
        }

        $this->document->addStyle('catalog/view/theme/journal2/lib/rs-plugin/css/settings.css');

        $this->document->addScript('catalog/view/theme/journal2/lib/rs-plugin/js/jquery.themepunch.plugins.min.js');
        $this->document->addScript('catalog/view/theme/journal2/lib/rs-plugin/js/jquery.themepunch.revolution.min.js');

        $this->template = 'journal2/template/journal2/module/fullscreen_slider.tpl';

        $this->data['module'] = $module++;

        $this->render();
    }

}